#include <iostream>
#include "../../xcom/xcom.hpp"

void test_memset()
{
    while(1)
    {
        auto begin = get_ns();
        void *p = mmap(NULL, 1052672, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) ;
        auto cost = get_ns() - begin;
        printf("cost=%ju\n",cost);
        
        if(nullptr == p)
        {
            printf("mmap err\n");
        }
        munmap(p,1052672);

        sleep_ns(X_NS_IN_SEC);
    }
}

void test_vector()
{
    vector<uint64_t> idxs;

    uint64_t last_cap = 0;
    for(int i = 0 ;i < 1200000000;i++)
    {
        auto begin = get_ns();
        idxs.push_back(i);
        auto cost = get_ns() - begin;

        auto cap = idxs.capacity();
        if(last_cap != cap || cost > 100*1000*1000)
        {
            printf("last_cap=%ju,cap=%ju,cost=%ju\n",last_cap,cap,cost/1000000);
            last_cap = cap;
        }
    }
}